home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / src / lib / gprim / geom / delete.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-20  |  1.7 KB  |  62 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #include "geomclass.h"
  13. #include "handleP.h"
  14.  
  15. int PoolDoCacheFiles;
  16.  
  17. void
  18. GeomDelete( object )
  19.     Geom *object;
  20. {
  21.     if (object == NULL)
  22.     return;
  23.  
  24.     /* If we're not caching contents of files, and this object was loaded
  25.      * from a file, and the sole reference to it is from the Handle,
  26.      * delete it now (and delete the handle and possibly close the file).
  27.      */
  28.     switch (RefDecr((Ref *)object)) {
  29.     case 1:
  30.     if(object->handle && object->handle->whence
  31.         && object->handle->object == (Ref *)object
  32.         && !PoolDoCacheFiles) {
  33.  
  34.         HandleDelete(object->handle);
  35.     }
  36.     return;
  37.     default:
  38.     if(object->ref_count < 0 || object->ref_count > 1000) { /* XXX debug */
  39.         OOGLError(1, "GeomDelete(%x) -- ref count %d?", object,
  40.         object->ref_count);
  41.         return;
  42.     }
  43.     return;
  44.     case 0:
  45.     /* Actually delete it */;
  46.     }
  47.  
  48.     if(object->ap) {
  49.     ApDelete(object->ap);
  50.     object->ap = NULL;
  51.     }
  52.     if(object->aphandle)
  53.     HandlePDelete(&object->aphandle);
  54.     if(object->Class->Delete) {
  55.     (*object->Class->Delete)(object);
  56.     }
  57.     if(object->handle && HandleObject(object->handle) == (Ref *)object)
  58.     HandleDelete(object->handle);
  59.     object->magic = -1;
  60.     OOGLFree(object);
  61. }
  62.